//============================================================================
// Name        : ms010.cpp
// Author      : Tadas
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include "lib.h"

#define H 1e-7

using namespace std;

const double L = 1e-6, C = 1e-6, R=0;

void funkcija(double t, double *y, double *deriv)
{ 
	deriv[0] = -y[1]/C;
	double temp = (y[0]-y[1]*R)/L;
	deriv[1] = temp;
}

void Dfunkcija( double t, double * y, double * deriv){
	deriv[0] = y[1];
	deriv[1] = -y[0];
}

int main()
{
	const int n = 100;
	double **y;
	double x[n], y1[n], y2[n];
	int i;

	
	y = allocate2d(n, lygsk);

	for (i=0; i<n; i++) x[i] = i*H;

	
	y[0][0] = 1;
	y[0][1] = 0;

	RK4solver(y, x, n, funkcija);

	for (i=0; i<n; i++)
	{
		y1[i]=y[i][0];
		y2[i]=y[i][1];
//		printf("%.4f:\t%.4f\t%.4f\n", x[i], y[i][0], y[i][1]);
		cout << "x: " << x[i] << " U: " << y[i][0] << " I: " << y[i][1] << endl;
	}


//	graphinit();
//
//	setaxis(x, y2, n);
//	plotgraph(x, y2, n, RED, 'l');


	deallocate2d(y, n);

	return 0;
}
